package com.freaky.widget;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.widget.TimePicker;

import com.freaky.paomian.R;
import com.freaky.widget.AdvancedTimePicker.OnTimeChangedListener;

/**
 * A dialog that prompts the user for the time of day using a {@link TimePicker}
 * .
 * 
 * <p>
 * See the <a href="{@docRoot}
 * resources/tutorials/views/hello-timepicker.html">Time Picker tutorial</a>.
 * </p>
 */
public class AdvancedTimePickerDialog extends AlertDialog implements
		OnClickListener, OnTimeChangedListener {
	private static String minute = "minute";
	private static String second = "second";

	private final OnTimeSetListener mCallBack;
	private final AdvancedTimePicker mTimePicker;

	private int mInitialMinute;
	private int mInitialSecond;

	/**
	 * @param context
	 *            Parent.
	 * @param theme
	 *            the theme to apply to this dialog
	 * @param callBack
	 *            How parent is notified.
	 * @param minute
	 *            The initial minute.
	 * @param second
	 *            The initial second.
	 */
	public AdvancedTimePickerDialog(Context context, int theme,
			OnTimeSetListener callBack, int minute, int second) {
		super(context, theme);
		// TODO Auto-generated constructor stub
		mCallBack = callBack;
		mInitialMinute = minute;
		mInitialSecond = second;
		mTimePicker=(AdvancedTimePicker)findViewById(R.id.timepicker_input);
		updateTitle(mInitialMinute, mInitialSecond);
		
		

	}

	public interface OnTimeSetListener {
		/**
		 * @param view
		 *            The view associated with this listener.
		 * @param minute
		 *            The minute that was set.
		 * @param second
		 *            The second that was set.
		 */
		void onTimeSet(AdvancedTimePicker view, int minute, int second);
	}

	@Override
	public void onTimeChanged(AdvancedTimePicker view, int minute, int second) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onClick(DialogInterface arg0, int arg1) {
		// TODO Auto-generated method stub

	}

	private void updateTitle(int minute, int second) {
		setTitle(minute+"+"+second);
	}
}
